package com.github.cakin.shiro.chapter12.web.mvc;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @className: AnnotationController
 * @description: 测试shiro的注解功能
 * @date: 2020/5/24
 * @author: cakin
 */
@Controller
public class AnnotationController {
    /**
     * 功能描述：不使用shiro注解的测试
     *
     * @author cakin
     * @date 2020/5/24
     */
    @RequestMapping("/hello1")
    public String hello1() {
        SecurityUtils.getSubject().checkRole("admin");
        return "success";
    }

    /**
     * 功能描述：使用shiro注解的测试
     *
     * @author cakin
     * @date 2020/5/24
     */
    @RequiresRoles("admin")
    @RequestMapping("/hello2")
    public String hello2() {
        return "success";
    }
}
